<!-- EC2 security group partial -->
<script id="services.ec2.regions.id.vpcs.id.security_groups.partial" type="text/x-handlebars-template">
    <div id="resource-name" class="list-group-item active">
      <h4 class="list-group-item-heading">{{name}}</h4>
    </div>

    <div class="list-group-item">
        <h4 class="list-group-item-heading">Information</h4>
        <div class="list-group-item-text">ID: <samp>{{id}}</samp></div>
        <div class="list-group-item-text">ARN: <samp>{{arn}}</samp></div>
        <div class="list-group-item-text">Region: <samp>{{region}}</samp></div>
        <div class="list-group-item-text">VPC: {{getValueAt 'services.vpc.regions' region 'vpcs' vpc 'name'}} ({{vpc}})</div>
        <div class="list-group-item-text">Description: <samp>{{description}}</samp></div>
    </div>

    {{#each rules}}
      {{> services.ec2.regions.vpcs.security_groups.rule_list this sg_name = ../name sg_id = ../id direction = @key vpc = ../vpc region = ../region }}
    {{/each}}

    <div class="list-group-item">
        <h4 class="list-group-item-heading">Usage</h4>
        {{#if used_by}}
        <ul>
            {{#each used_by}}
                {{#each resource_type}}
                    {{> services.ec2.regions.vpcs.security_groups.resource_list service=@../key resources=this resource_type=@key status=this region=../../region vpc=../../vpc group=../../../id}}
                {{/each}}
            {{/each}}
        </ul>
        {{else}}
        <span id="services.ec2.regions.vpcs.security_groups-unused-{{id}}" class="finding-hidden item-margin">
            <i class="fa fa-check-circle"></i> This security group is not in use.
        </span>
        {{/if}}
    </div>
</script>

<script>
  Handlebars.registerPartial("services.ec2.regions.id.vpcs.id.security_groups", $("#services\\.ec2\\.regions\\.id\\.vpcs\\.id\\.security_groups\\.partial").html());
</script>

<!-- Single EC2 security group template -->
<script id="single_ec2_security_group-template" type="text/x-handlebars-template">
  {{> modal-template template='services.ec2.regions.id.vpcs.id.security_groups'}}
</script>

<script>
  var single_ec2_security_group_template = Handlebars.compile($("#single_ec2_security_group-template").html());
</script>
